<!-- BeginDsi "dsi/head.html" -->
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Embedthis GoAhead 3.1.1 Documentation</title>
    <meta name="keywords" content="embedded web server, web server software, embedded HTTP, application web server, 
        embedded server, small web server, HTTP server, library web server, library HTTP, HTTP library" />
    <meta name="description" content="Embedthis Sofware provides commercial and open source embedded web servers for 
        devices and applications." />
	<meta name="robots" content="index,follow" />
	<link href="../../../doc.css" rel="stylesheet" type="text/css" />
	<link href="../../../print.css" rel="stylesheet" type="text/css" media="print"/>
    <!--[if IE]>
    <link href="../../../iehacks.css" rel="stylesheet" type="text/css" />
    <![endif]-->
    <link href="http://www.google.com/cse/style/look/default.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-179169-5']);
        _gaq.push(['_trackPageview']);
        (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
</head>

<body>
    <div class="top">
        <a class="logo" href="http://embedthis.com/products/goahead/">&nbsp;</a>
        <div class="topRight">
            <div class="search">
                <div id="cse-search-form"></div>
                <div class="version">Embedthis GoAhead 3.1.1</div>
            </div>
        </div>
        <div class="crumbs">
            <a href="../../../index.html">Home</a>
<!-- EndDsi -->
             &gt; <a href="index.html">Programming Guide</a> &gt; <b>Serving Pages from ROM</b>
        </div>
    </div>
    <div class="content">
        <div class="contentRight">
            <h1>Quick Nav</h1>
            <ul>
                <li><a href="#compilingWebPages">Compiling Web Pages</a></li>
            </ul>
<!-- BeginDsi "dsi/progGuideSeeAlso.html" -->
            <h1>See Also</h1>
            <ul class="nav">
                <li><a href="../../../guide/goahead/programmers/index.html">Programmers Guide</a></li>
                <li><a href="../../../guide/goahead/programmers/embedding.html">Embedding GoAhead</a></li>
                <li><a href="../../../guide/goahead/programmers/handlers.html">Custom Handlers</a></li>
                <li><a href="../../../guide/goahead/programmers/migrating.html">Migrating to GoAhead 3</a></li>
                <li><a href="../../../guide/goahead/programmers/rom.html">ROM Content</a></li>
                <li><a href="../../../ref/goahead/index.html">Programmers Reference</a></li>
                <li><a href="../../../guide/goahead/users/index.html">Users Guide</a></li>
            </ul>
<!-- EndDsi -->
        </div>
        <div class="contentLeft">
            <h1>Serving Pages from ROM</h1>
            <p>To enable GoAhead to be used on embedded systems without file systems, GoAhead supports the compilation of
            web pages and configuration files into C code that can be stored in Read-Only-Memory (ROM) and fetched by
            GoAhead to respond to relevant requests.</p>
            <p>GoAhead has a virtual file system interface that allows the run-time switching between serving web pages
            on a disk-based file system and a compiled ROM based store of web pages.
            This ROM facility may also be used to enhance security by preventing the modification of web documents,
            or in performance critical situations were the serving of web pages from memory may be an effective
            optimization.</p>
            
            <a id="compilingWebPages"></a>
            <h2 class="section">Compiling Web Pages</h2>
            <p>The GoAhead <b>webcomp</b> program is used to compile web documents, configuration files, and any other
            files that you would like to be compiled into C code. The webcomp program will parse the files and convert
            them into C data structures which can then be compiled by your C/C++ compiler and linked into your
            application.</p>
            <p>For example:</p>
            <pre>
find web -print &gt;fileList
webcomp filelist &gt;romFiles.c
</pre>
            <p>This will create a list of all the web files and then convert these files into C structures in the file
            romFiles.cpp.</p>
            <p>The <b>webcomp</b> program takes one options:</p>
            <table title="Switches" class="width">
                <thead>
                    <tr>
                        <th>Switch</th>
                        <th>Description</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>--prefix</td>
                        <td>Specifies a prefix to remove from each of the compiled file names.</td>
                    </tr>
                </tbody>
            </table>
            <p>It is important to include some essential GoAhead configuration files into the ROM. These include the
            GoAhead configuration file, the mime.types file, and any authorization database files. The following script
            is used to compile the web pages in three web directories ("sslWeb", "vhostWeb", and "web") and to also
            compile the essential configuration files. Note: the files should be relative paths without a "./" prefix.</p>
            <pre>
find sslWeb vhostWeb web -print &gt;rom.files \
echo -e '.\ngoahead.conf\nmime.types\nusers.db\ngroups.db' &gt;&gt;rom.files
webcomp rom.files &gt;romFiles.c
</pre>
        </div>
    </div>
<!-- BeginDsi "dsi/bottom.html" -->
	<div class="bottom">
		<p class="footnote"> 
            <a href="../../../product/copyright.html" >&copy; Embedthis Software LLC, 2003-2013.
            All rights reserved. Embedthis and Embedthis GoAhead are trademarks of Embedthis Software LLC.</a>
		</p>
	</div>
    <script src="http://www.google.com/jsapi" type="text/javascript"></script>
    <script type="text/javascript"> 
      google.load('search', '1', {language : 'en'});
      google.setOnLoadCallback(function() {
        var customSearchControl = new google.search.CustomSearchControl(
          '000262706376373952077:1hs0lhenihk');
        customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
        var options = new google.search.DrawOptions();
        options.enableSearchboxOnly("http://embedthis.com/search.html");
        customSearchControl.draw('cse-search-form', options);
      }, true);
    </script>
</body>
</html>
